<<<<<<< HEAD
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Recharge extends CI_Controller {
	function __construct(){
		parent::__construct();
		
	}
	function index(){
		$user = $this->session->userdata('rsh_user');
		if(isset($user['user_id']) && $user['user_id'] > 0){
			
			if (time()>=strtotime('2014-04-19')){
				$ret['msg'] = '线下充值已关闭，请前往官网使用线上充值';
				$ret['url_title'] = '返回';
				$ret['url_next']="/mobile/ucenter.html";
				$this->load->view('mobile/msg',$ret);
			}else{
				$this->load->model('User_model', 'user');
				$user = $this->user->get_by_uid($user['user_id']);
				$this->load->view('mobile/recharge',$user);
			}
		}else{
			header('Location: /mobile/login/index/index.html');
		}
	}
	
	function submit(){
		$user = $this->session->userdata('rsh_user');
		if(isset($user['user_id']) && $user['user_id'] > 0){
			$type = 2;
			$money = $this->input->post('money');
			if(!is_numeric($money)){
				$ret['msg'] = '无效的金额';
				$ret['url_title'] = '返回';
				$ret['url_next']="/mobile/recharge.html";
				$this->load->view('mobile/msg',$ret);
			}else{
				$money = round($money,2);
				if ($money <= 0){
					$ret['msg'] = '无效的金额';
					$ret['url_title'] = '返回';
					$ret['url_next']="/mobile/recharge.html";
					$this->load->view('mobile/msg',$ret);
				}else{
					$payment = '0';
					$remark = $this->input->post('bankinfo').' 订单号：'. $this->input->post('remark');
					$fee = 0;
					$time = time();
					$recharge = array(
						'user_id' => $user['user_id'],
						'trade_no' => $time.$user['user_id'].rand(1,9),
						'fstatus' => 0,
						'money' => $money,
						'payment' => $payment,
						'freturn' => '',
						'ftype' => $type,
						'remark' => $remark,
						'fee' => $fee,
						'verify_userid' => 0,
						'verify_time' => $time,
						'verify_ip' => '',
						'verify_remark' => '',
						'add_time' => $time,
						'addip' => $this->input->ip_address()
					);
					$this->load->model('User_model', 'user');
					$userAll = $this->user->get_by_uid($user['user_id']);
					if($userAll['real_status'] == 1){
						$this->load->model('Accountrecharge_model', 'recharge');
						$res = $this->recharge->add($recharge);
						if($res > 0){
							$ret['msg'] = '充值已提交，请等待审核';
							$ret['url_title'] = '返回用户中心';
							$ret['url_next']="/mobile/ucenter.html";
							$this->load->view('mobile/msg',$ret);
						}else{
							$ret['msg'] = '提交失败';
							$ret['url_title'] = '返回';
							$ret['url_next']="/mobile/recharge.html";
							$this->load->view('mobile/msg',$ret);
						}
					}else{
						$ret['msg'] = '尚未实名认证';
						$ret['url_title'] = '返回';
						$ret['url_next']="/mobile/recharge.html";
						$this->load->view('mobile/msg',$ret);
					}
				}	
			}
		}else{
			header('Location: /mobile/login/index/index.html');
		}
	}
=======
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Recharge extends CI_Controller {
    function __construct(){
		parent::__construct();
		
	}
	function index(){
		$user = $this->session->userdata('rsh_user');
		if(isset($user['user_id']) && $user['user_id'] > 0){
			
			if (time()>=strtotime('2014-04-19')){
				$ret['msg'] = '线下充值已关闭，请前往官网使用线上充值';
				$ret['url_title'] = '返回';
				$ret['url_next']="/mobile/ucenter.html";
				$this->load->view('mobile/msg',$ret);
			}else{
				$this->load->model('User_model', 'user');
				$user = $this->user->get_by_uid($user['user_id']);
				$this->load->view('mobile/recharge',$user);
			}
		}else{
			header('Location: /mobile/login/index/index.html');
		}
	}
	
	function submit(){
		$user = $this->session->userdata('rsh_user');
		if(isset($user['user_id']) && $user['user_id'] > 0){
			$type = 2;
			$money = $this->input->post('money');
			if(!is_numeric($money)){
				$ret['msg'] = '无效的金额';
				$ret['url_title'] = '返回';
				$ret['url_next']="/mobile/recharge.html";
				$this->load->view('mobile/msg',$ret);
			}else{
				$money = round($money,2);
				if ($money <= 0){
					$ret['msg'] = '无效的金额';
					$ret['url_title'] = '返回';
					$ret['url_next']="/mobile/recharge.html";
					$this->load->view('mobile/msg',$ret);
				}else{
					$payment = '0';
					$remark = $this->input->post('bankinfo').' 订单号：'. $this->input->post('remark');
					$fee = 0;
					$time = time();
					$recharge = array(
						'user_id' => $user['user_id'],
						'trade_no' => $time.$user['user_id'].rand(1,9),
						'fstatus' => 0,
						'money' => $money,
						'payment' => $payment,
						'freturn' => '',
						'ftype' => $type,
						'remark' => $remark,
						'fee' => $fee,
						'verify_userid' => 0,
						'verify_time' => $time,
						'verify_ip' => '',
						'verify_remark' => '',
						'add_time' => $time,
						'addip' => $this->input->ip_address()
					);
					$this->load->model('User_model', 'user');
					$userAll = $this->user->get_by_uid($user['user_id']);
					if($userAll['real_status'] == 1){
						$this->load->model('Accountrecharge_model', 'recharge');
						$res = $this->recharge->add($recharge);
						if($res > 0){
							$ret['msg'] = '充值已提交，请等待审核';
							$ret['url_title'] = '返回用户中心';
							$ret['url_next']="/mobile/ucenter.html";
							$this->load->view('mobile/msg',$ret);
						}else{
							$ret['msg'] = '提交失败';
							$ret['url_title'] = '返回';
							$ret['url_next']="/mobile/recharge.html";
							$this->load->view('mobile/msg',$ret);
						}
					}else{
						$ret['msg'] = '尚未实名认证';
						$ret['url_title'] = '返回';
						$ret['url_next']="/mobile/recharge.html";
						$this->load->view('mobile/msg',$ret);
					}
				}	
			}
		}else{
			header('Location: /mobile/login/index/index.html');
		}
	}
>>>>>>> d47623b610d79a4eeb489500830c00d70933f414
}